import pygame
import sys
import time
import random
from pygame.locals import *
from bar import Bar
from pygame.sprite import Sprite, Group
from cube import Cube
from ball import Ball
from arkanoid_reader import Reader
from arkanoid_errors import UserDisq
from arkanoid_game import Game


life = 1
screen_dimension = ( 800, 400 )
pygame.init()
screen = pygame.display.set_mode( screen_dimension )
pygame.mouse.set_visible(False)

stage = 1
game = Game(stage, screen)

#screen = pygame.display.set_mode( (800,400), pygame.FULLSCREEN )     

while True:
    try:
        game.handle_collisions()
        if game.is_done():
            stage = stage + 1
            game = Game(stage, screen)
        if game.is_end():
            game.end_game()
            stage = 1
            time.sleep(1)
        else:
            game.draw()
            time.sleep(0.06)
        
    except UserDisq as e:
        game.disqualify()